package gui;

import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JFrame;
import javax.swing.JLabel;

import utils.DateUtils;


public class DateFormListener implements MouseListener{
	
	private JLabel dateForm;
	private JFrame mainW;
	private Color rollColor = new Color(0,155,255);
	
	
	public DateFormListener(JLabel l, JFrame main){
		dateForm = l;
		mainW = main;
	}
	
	@Override
	public void mouseClicked(MouseEvent arg0) {
		
		switch (arg0.getButton()) {
		case MouseEvent.BUTTON1:
			Thread t = new Thread(new Runnable() {
				public void run() {
					DateSumWindow dateSum = new DateSumWindow(dateForm, DateUtils.getDate());
					mainW.setEnabled(false);
					dateSum.waitFor();
					mainW.setEnabled(true);
				}
			});
			t.start();
			break;

		default:
			break;
		}
		
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		dateForm.setForeground(rollColor);
		
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		dateForm.setForeground(Color.DARK_GRAY);
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
	}

}
